const path = require('path');
const webpack = require('webpack')
const {merge} = require('webpack-merge')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const {CleanWebpackPlugin} = require('clean-webpack-plugin')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const CommonWebpackConfig = require('./webpack.common')

const DevWebpackConfig = merge(CommonWebpackConfig, {
  devtool: 'inline-source-map',
  devServer: {
    port: '8088',
    contentBase: './dist',
     hot: true
  },
  plugins:[
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: './public/index.html',
      inject: true
    }),
    new VueLoaderPlugin(),
    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, './src/assets'),
        to: 'assets',
        ignore: ['.*']
      },
      {
        from: path.resolve(__dirname, './public/favicon.ico'),
        // to: 'dist',
        // ignore: ['.*']
      }
    ]),
    new webpack.HotModuleReplacementPlugin(),
  ]
})
module.exports = DevWebpackConfig